
const { decrypt } = require('../utils');
const CallbackService = require('../services/callback')
module.exports = app => {
  app.post(`${process.env.VUE_APP_BASE_API}/common/callback`, (req, res) => {
    const { body } = req;
    const decryptBody = decrypt(body.encrypt);
    console.log('decryptBody = ', decryptBody);
    if (decryptBody?.MsgType === 'FlowStatusChange') {// 签署操作
      const callbackService = new CallbackService();
      callbackService.handleContracts(decryptBody.MsgData);
    }else if(decryptBody?.MsgType === 'OperateSeal'){ // 印章操作
    }else if(decryptBody?.MsgType.includes('Template')){ // 模板操作 
      // TemplateAdd：创建模板
      // TemplateUpdate：编辑模板
      // TemplateDelete： 删除模板
    }else if(decryptBody?.MsgType === 'VerifyStaffInfo' || decryptBody?.MsgType === 'RolesChange' ){ // 员工操作
      // VerifyStaffInfo 员工认证成功
      // RolesChange 员工变更角色
    }
    res.status(200).json({
      message: 'ok',
    });
  });
};